package com.flinkjar.flinkjardemo.bean;



import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;


/**
 * 用户商品
 */

public class UserProduct extends BaseBean implements Serializable, TableIndex {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    private Long id;

    /**
     * 用户ID
     */
    private String userId;

    /**
     * 商品ID
     */
    private String productId;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    @Override
    public String toString() {
        return "UserProduct{" +
                "id=" + id +
                ", userId='" + userId + '\'' +
                ", productId='" + productId + '\'' +
                ", operation=" + operation +
                '}';
    }


    @Override
    public int getTableIndex(int tableCount) {
        if (StringUtils.isNotBlank(userId)) {
            return Math.abs(userId.hashCode()) % tableCount;
        }
        return 0;
    }

}
